<template>
  <el-button type="success" class="btn" @click="confirm">一建初始化</el-button>
  <br />
  <el-button type="primary" style="margin-top:80px" @click="step"
    >下一步
  </el-button>
  <!-- <el-dialog
    v-model="dialogVisible"
    width="35%"
    custom-class="dialon"
    :show-close='false'
    :close-on-press-escape='false'
    :close-on-click-modal='false'
  >
    <span class="dialon-span">是否初始化KDC</span>
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="confirm"
          >确认</el-button
        >
        <el-button @click="cancel">取消</el-button>
      </span>
    </template>
  </el-dialog> -->
</template>

<script>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import request from "../../http/request";
import { ElNotification } from "element-plus";
import store from "../../store";
export default {
  setup(props) {
    const router = useRouter();
    const dialogVisible = ref(false);
    const userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
    const confirm = async () => {
      // 发送初始化的请求
      const { data } = await request.init({
        user_id: userInfo.user_id,
      });
      if (data.code === 0) {
        ElNotification({
          title: "消息提示",
          message: "请求成功",
          position: "bottom-right",
        });
      }
      // dialogVisible.value = false;
      // router.push({
      //   path: "/home/tabs/center",
      // });
    };
    const cancel = () => {
      dialogVisible.value = false;
      router.push({
        path: "/home/tabs/star",
      });
    };
    onMounted(() => {
      dialogVisible.value = true;
    });
     const step = () => {
       router.push("/home/tabs/center")
      store.commit("CHANGE1", false);
    };
    return {
      dialogVisible,
      confirm,
      cancel,
      step
    };
  },
};
</script>

<style scoped>
.btn{
  margin-top:30px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
.dialon {
  text-align: left;
}
.dialon-span {
  text-align: left;
  font-size: 20px !important;
}
</style>